#include<iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int** a = new int* [2];
		for (int j = 0; j < 2; j++) {
			a[j] = new int[3];
		}
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 3; k++) {
				cin >> a[j][k];
			}
		}
		for (int j = 2; j >= 0; j--) {
			for (int k = 0; k < 2; k++) {
				cout << *(*(a + k) + j) << ' ';
			}
			cout << endl;
		}
	}
}